package fr.pascal.client.activity;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import fr.pascal.client.ClientFactory;
import fr.pascal.client.place.DetailPlace;
import fr.pascal.client.ui.DetailView;

public class DetailActivity extends AbstractActivity {
	
	private ClientFactory clientFactory;
	private int animalId;
	
	public DetailActivity(ClientFactory clientFactory, DetailPlace detailPlace) {
		this.clientFactory = clientFactory;
		this.animalId = Integer.valueOf(detailPlace.getAnimalId());
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		DetailView detailView = clientFactory.getDetailView();
		detailView.setDetailAnimal(DetailsAnimaux.detailAnimal(animalId));
		panel.setWidget(detailView.asWidget());
	}
}
